/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.intec.matsab.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Sabrina
 */
@Entity
@Table(name = "Seccion")
@NamedQueries({@NamedQuery(name = "Seccion.findByNumero", query = "SELECT s FROM Seccion s WHERE s.seccionPK.numero = :numero"), @NamedQuery(name = "Seccion.findByIdTrimestre", query = "SELECT s FROM Seccion s WHERE s.seccionPK.idTrimestre = :idTrimestre"), @NamedQuery(name = "Seccion.findByIdAsignatura", query = "SELECT s FROM Seccion s WHERE s.seccionPK.idAsignatura = :idAsignatura")})
public class Seccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SeccionPK seccionPK;
    @JoinColumn(name = "idAsignatura", referencedColumnName = "idAsignatura", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Asignatura asignatura;
    @JoinColumn(name = "idTrimestre", referencedColumnName = "idTrimestre", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Trimestre trimestre;
    @JoinColumn(name = "idEstado", referencedColumnName = "idEstado")
    @ManyToOne(optional = false)
    private Estado idEstado;
    @JoinColumn(name = "idProfesor", referencedColumnName = "idProfesor")
    @ManyToOne
    private Profesor profesor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "seccion")
    private Collection<Clase> claseCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "seccion")
    private Collection<Historial> historialCollection;

    public Seccion() {
    }
    public Seccion(SeccionPK seccionPK) {
        this.seccionPK = seccionPK;
    }

    public Seccion(SeccionPK seccionPK, Profesor profesor) {
        this.seccionPK = seccionPK;
        this.profesor = profesor;
    }

    public Seccion(int numero, int idTrimestre, String idAsignatura) {
        this.seccionPK = new SeccionPK(numero, idTrimestre, idAsignatura);
    }

    public SeccionPK getSeccionPK() {
        return seccionPK;
    }

    public void setSeccionPK(SeccionPK seccionPK) {
        this.seccionPK = seccionPK;
    }

    public Profesor getProfesor() {
        return profesor;
    }

    public void setProfesor(Profesor profesor) {
        this.profesor = profesor;
    }

    public Collection<Historial> getHistorialCollection() {
        return historialCollection;
    }

    public void setHistorialCollection(Collection<Historial> historialCollection) {
        this.historialCollection = historialCollection;
    }

    public Collection<Clase> getClaseCollection() {
        return claseCollection;
    }

    public void setClaseCollection(Collection<Clase> claseCollection) {
        this.claseCollection = claseCollection;
    }

    public Asignatura getAsignatura() {
        return asignatura;
    }

    public void setAsignatura(Asignatura asignatura) {
        this.asignatura = asignatura;
    }

    public Trimestre getTrimestre() {
        return trimestre;
    }

    public void setTrimestre(Trimestre trimestre) {
        this.trimestre = trimestre;
    }

    public Estado getIdEstado() {
        return idEstado;
    }

    public void setIdEstado(Estado idEstado) {
        this.idEstado = idEstado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (seccionPK != null ? seccionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Seccion)) {
            return false;
        }
        Seccion other = (Seccion) object;
        if ((this.seccionPK == null && other.seccionPK != null) || (this.seccionPK != null && !this.seccionPK.equals(other.seccionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.intec.matsab.persistence.Seccion[seccionPK=" + seccionPK + "]";
    }

}
